package szkeleton;
import java.io.*;

import javax.swing.JOptionPane;
import javax.swing.Timer;
public class Main {
	public static void main(String[] args)
	{
		Controller ctrl = new Controller(false);
		Gamelogic.controller=ctrl;
		File saveFile = new File("./saveFile.txt");
		if(saveFile.exists())
		{
			ctrl.loadSave(saveFile);
		}else 
		{
		  try
		  { 
			  FileWriter fstream = new FileWriter(saveFile);
			  BufferedWriter out = new BufferedWriter(fstream);
			  out.write("./map/map1.txt");
			  out.close();
			  ctrl.loadSave(saveFile);
		  }
		  catch (Exception e)
		  { 
			  JOptionPane.showMessageDialog(null,"Irasi hiba", "Hiba",JOptionPane.ERROR_MESSAGE);
				System.exit(0);
		  }
		}
		
        Timer timer =new Timer(50,ctrl);
		timer.start();
		try
		{
		/*if (args.length>0) ctrl.ParseCommandFile(args[0]); else
		{
			System.out.println("Mi legyen?");
			InputStreamReader isr = new InputStreamReader(System.in);
			BufferedReader br = new BufferedReader(isr);
			String cmd;
			while ((cmd=br.readLine()) !=null)
			{
				ctrl.ParseCommand(cmd, ctrl.InterpretCommand(cmd));
				System.out.println();
			}
		}
		*/
		
		}
		catch (Exception e)
		{
			Gamelogic.getController().getView().showError(e.getMessage());
			//System.out.println(e.getMessage());
		}
		
	}
}
